<%-- 
    Document   : mysso
    Created on : 2010-1-29, 11:20:15
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.util.*"%>
<%@ page import="com.mysap.sso.*"%>
<%@ page import="com.mysap.sso.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>MYSSO</title>
    </head>
    <body>
        <% Cookie[] all_Cookies = request.getCookies();
            String ticket = "";
            int i = 0;
            if (all_Cookies == null) {
                out.println("all_Cookies==null");
            } else {
                for (i = 0; i < all_Cookies.length; i++) {
                    if ("MYSAPSSO2".equals(all_Cookies[i].getName())) {
                        ticket = all_Cookies[i].getValue();
                        System.out.println(ticket);
                        ticket = (java.net.URLDecoder.decode(ticket, "utf-8")).trim();   
                                         
                        break;
                    }
                }
            }
            String Path = request.getScheme() + "://"+ request.getServerName() + ":"+ request.getServerPort() + request.getContextPath() + "/";
			     
            
            if ("".equals(ticket)) {            
            
				String pageURl = Path + "LogonAction.shtml?method=execute_noLogin&josso_username=default";
				response.sendRedirect(pageURl);
				   //System.out.println(">>>>>>>>>ticket is empty");   
        %>
            <%    } else {
          //  System.out.println(">>>>>>>>>ticket is getted");  
             //SSO2Ticket ticketParse = new SSO2Ticket();
             //ticketParse.parseTicket(ticket);
             //session.setAttribute("user",ticketParse.getUser());  
             session.setAttribute("user","chenzh"); 
   
               //String pageURl = Path + "LogonAction.do?method=execute_Login&josso_username="+ticketParse.getUser();
             String pageURl = Path + "LogonAction.do?method=execute_Login&josso_username="+"chenzh";
				response.sendRedirect(pageURl);
             
			
            }
        %>
    </body>
</html>
